package com.gooboot.kadmin.base.config;

import io.swagger.annotations.ApiOperation;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

public class BaseSwagger2 {

    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(this.apiInfo())
                .select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title(this.getDocTitle())
                .description(this.getDocDescription())
                .version(this.getDocVersion())
                .build();
    }

    public String getDocTitle(){
        return "接口文档";
    }

    public String getDocDescription(){
        return "restful风格的文档";
    }

    public String getDocVersion(){
        return "1.0";
    }
}
